<?php

/**
 * RestAdminBaseController控制器注意：
 * 请求接口，header必须带入字段：
 * Authorization 或 XX-Token，XX-Token=$token即可，Authorization要带“Bearer ”=Bearer $token
 * XX-Device-Type=web
 * 获得管理员id不能用cmf_get_current_admin_id()函数，要用类属性
 * $this->userId;
 * $this->user;
 * $this->userType;
 */

namespace api\v1\controller;

use api\v1\service\XmService;
use think\facade\Db;
use think\Validate;
use cmf\controller\RestAdminBaseController;

class XmController extends RestAdminBaseController
{
    /**
     * 显示资源列表
     */
    public function index()
    {
        $filter = $this->request->param('filter/a');
        $param = $this->request->param('param/a');
        //dump($filter);
        $xmservice = new XmService();
        $res = $xmservice->getXmList($filter, $param);
        $this->success('', $res);
    }

    /**
     * 取得登录用户的未完结项目列表
     */
    public function getUserXmList()
    {
        $uid = $this->userId;
        $filter = $this->request->param('filter/a');
        $param = $this->request->param('param/a');
        $filter['xmjl_id'] = $uid;  //只能查看自己的项目
        //dump($filter);
        $xmservice = new XmService();
        $res = $xmservice->getXmList($filter, $param);
        $this->success('', $res);
    }

    /**
     * 保存新建的资源
     */
    public function save() {}

    /**
     * 显示指定的资源
     *
     * @param  int $id
     */
    public function read($id) {}

    /**
     * 保存更新的资源
     *
     * @param  int $id
     */
    public function update($id) {}

    /**
     * 删除指定资源
     *
     * @param  int $id
     */
    public function delete($id) {}
}
